package com.mxchip.livestarmobile.mobile.ui.call

import android.app.Application
import androidx.lifecycle.*
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class CallControlViewModel (application: Application) : AndroidViewModel(application) {

    private var job: Job? = null

    private val isShow = MutableLiveData<Boolean>(false)

    fun isShow(): LiveData<Boolean> {
        return isShow
    }

    fun touched() {
        if(isShow.value == false) {
            isShow.value = true

            job?.cancel()
            job = viewModelScope.launch {
                delay(3000)
                isShow.value = false
            }
        } else {
            job?.cancel()
            job = null
            isShow.value = false
        }
    }
}
